import sys
import math

# pypy3能过


def inp() -> str:
    return sys.stdin.readline().strip("\n").strip(" ")


n = int(inp())
a = [0] + list(map(int, inp().split(" ")))
t = [0] * ((n + 1) * 4)
b = [0] * ((n + 1) * 4)


def build(rt: int = 1, l: int = 1, r: int = n) -> None:
    if l == r:
        t[rt] = a[l]
        b[rt] = a[l]
        return
    mid = (l + r) // 2
    build(rt << 1, l, mid)
    build(rt << 1 | 1, mid + 1, r)
    t[rt] = t[rt << 1] + t[rt << 1 | 1]
    b[rt] = max(b[rt << 1], b[rt << 1 | 1])


def sqrt(L: int, R: int, rt: int = 1, l: int = 1, r: int = n) -> None:
    if b[rt] == 1:
        return
    if l == r:
        t[rt] = int(math.sqrt(t[rt]))
        b[rt] = t[rt]
        return
    mid = (l + r) // 2
    if L <= mid:
        sqrt(L, R, rt << 1, l, mid)
    if R > mid:
        sqrt(L, R, rt << 1 | 1, mid + 1, r)
    t[rt] = t[rt << 1] + t[rt << 1 | 1]
    b[rt] = max(b[rt << 1], b[rt << 1 | 1])


def query(L: int, R: int, rt: int = 1, l: int = 1, r: int = n) -> int:
    if L <= l and r <= R:
        return t[rt]
    mid, ret = (l + r) // 2, 0
    if L <= mid:
        ret = query(L, R, rt << 1, l, mid)
    if R > mid:
        ret += query(L, R, rt << 1 | 1, mid + 1, r)
    return ret


build()
for q in range(int(inp())):
    opt, l, r = map(int, inp().split(" "))
    if l > r:
        l, r = r, l
    if opt == 0:
        sqrt(l, r)
    else:
        sys.stdout.write(str(query(l, r)) + "\n")
